<div class="doc-item" id="doc-1330"><h2 class="doc-item-name">show<span class="namespace">(clojure.contrib.repl-utils)</span></h2><ul class="var-arglists"><li>(<span class="var-name">show</span>  x)</li><li>(<span class="var-name">show</span> x selector)</li></ul><div class="var-docstring"><p>With one arg prints all static and instance members of x or (class x).
  Each member is listed with a number which can be given as 'selector'
  to return the member object -- the REPL will print more details for
  that member.</p><p>The selector also may be a string or regex, in which case only
  members whose names match 'selector' as a case-insensitive regex
  will be printed.</p><p>Finally, the selector also may be a predicate, in which case only
  members for which the predicate returns true will be printed.  The
  predicate will be passed a single argument, a map that includes the
  :text that will be printed and the :member object itself, as well as
  all the properies of the member object as translated by 'bean'.</p><p>Examples: (show Integer)  (show [])  (show String 23)  (show String &quot;case&quot;)</p></div><div class="var-source"><pre>; clojure/contrib/repl_utils.clj:59
(defn show
  ([x] (show x (constantly true)))
  ([x selector]
      (let [c (if (class? x) x (class x))
            members (sort-by :sort-val
                             (map member-details
                                  (concat (.getFields c)
                                          (.getMethods c)
                                          (.getConstructors c))))]
        (if (number? selector)
          (:member (nth members selector))
          (let [pred (if (ifn? selector)
                       selector
                       #(re-find (re-pattern (str &quot;(?i)&quot; selector)) (:name %)))]
            (println &quot;=== &quot; (Modifier/toString (.getModifiers c)) c &quot; ===&quot;)
            (doseq [[i m] (indexed members)]
              (when (pred m)
                (printf &quot;[%2d] %s\n&quot; i (:text m)))))))))</pre></div><div class="license"><p>Copyright (c) Rich Hickey. All rights reserved.</p><p>The use and distribution terms for this software are covered by the <a href="http://opensource.org/licenses/eclipse-1.0.php">Eclipse Public License 1.0</a>, which can be found in the file
          epl-v10.html at the root of this distribution. By using this software
          in any fashion, you are agreeing to be bound by the terms of this
          license. You must not remove this notice, or any other, from this
          software.</p></div></div>